//
//  BasePlayVC.swift
//  ImGuider X
//
//  Created by 王鹏宇 on 10/29/18.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class BasePlayVC: BaseVC {
   
    var isPlayAlways : Bool = false
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        becomeFirstResponder()
        UIApplication.shared.beginReceivingRemoteControlEvents()
          isPlayAlways = false
    }
    
    override func viewWillDisappear(_ animated: Bool) {
       
         super.viewWillDisappear(animated)
        
        resignFirstResponder()
        UIApplication.shared.endReceivingRemoteControlEvents()
        
    }
    
    
    override func remoteControlReceived(with event: UIEvent?) {
        
        guard let Event = event else {
            return
        }
        if (Event.type == .remoteControl) {
            
            switch (Event.subtype) { // 得到事件类型
                
            case .remoteControlTogglePlayPause : // 暂停 ios6
                WPY_AVPlayer.playManager.pause()
                
                // 调用你所在项目的暂停按钮的响应方法 下面的也是如此
                break;
                
            case .remoteControlPreviousTrack :  // 上一首
                WPY_AVPlayer.playManager.previous()
                
                break;
                
            case .remoteControlNextTrack: // 下一首
                WPY_AVPlayer.playManager.next()
                
                break;
                
            case .remoteControlPlay : //播放
                WPY_AVPlayer.playManager.play()
                break;
                
            case .remoteControlPause: // 暂停 ios7
                // [self actionStopButton:self.musicViewNew.stopButton];
                WPY_AVPlayer.playManager.pause()
                
                break;
                
            default:
                
                break;
            }
        }
    }

}
